package com.inkyi.assistant.app.todolist.right;

import com.formdev.flatlaf.FlatLightLaf;
import com.inkyi.assistant.app.todolist.TodoContext;

import javax.swing.*;

public class TodoRightPanel extends JSplitPane {

    private TodoRightMainContent mainContent;
    private TodoRightDrawerContent drawerContent;

    public TodoRightPanel() {
        initComponents();
    }

    private void initComponents() {
        mainContent = new TodoRightMainContent();
        this.setLeftComponent(mainContent);
        drawerContent = new TodoRightDrawerContent();
        this.setRightComponent(drawerContent);
        TodoContext.setTodoRightPanel(this);
        TodoContext.setTodoRightDrawerContent(drawerContent);
        TodoContext.setTodoRightMainContent(mainContent);
        // 默认隐藏右侧面板
        this.getRightComponent().setVisible(false);
    }


    public void visibleDrawer(boolean visible) {
        this.getRightComponent().setVisible(visible);
        if (visible) {
            this.setDividerLocation(0.7);
        }
    }

    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(new FlatLightLaf());
        } catch (Exception ex) {
            System.err.println("Failed to initialize LaF");
        }

        TodoRightPanel contentPane = new TodoRightPanel();
        JFrame frame = new JFrame();
        frame.setSize(800, 600);
        frame.setContentPane(contentPane);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}
